<?php
$this->breadcrumbs=array(
	'Bt Batteries'=>array('admin'),
	'管理',
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$(this).toggleClass('collapse');
	$('fieldset').toggleClass('collapsed');
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('dict-battery-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<div id="page-header">
	<h1>管理<?php echo $this->moduleName; ?></h1>
    <div id="page-options">
	<?php $this->renderPartial('_menu',array(
    'model'=>$batterys,
    )); ?>
    </div>
</div>


<?php   $this->renderPartial('_search',array(
  'bases'=>$bases,'batterys'=>$batterys
 	 ));   ?>


<section class="grid_9" id="dashtabs">
<div class="box-header">
  <?php echo $this->moduleName."列表"; ?></div>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	//'id'=>'bt-battery-grid',
	'dataProvider'=>$batterys,
	//'filter'=>$model,
		'htmlOptions'=>array(
				'class'=>'cgridview'
		),
	'columns'=>array(
 
			array(
					'header' => '流水号',
					'value' => '$row + 1',
			),   
 
		array(
		'type'=>'html',
		'header'=>'电池组名称',//显示表名称	
		'name'=>'GROUPNAME_V'	,
		//'urlExpression'=>'Yii::app()->createUrl("btBatterys/details",array("status"=>1, "start_time"=>Yii::app()->controller->start_time))',//显示URL
		'value' => 'CHtml::link($data["GROUPNAME_V"], array("btBattery/admin", 
				"RECORD_ID"=>$data["RECORD_ID"], "searchByUid"=>Yii::app()->controller->searchByUid,
				"base_id"=>Yii::app()->controller->base_id,
		))',
	),	 
	array(
					'header' => '电池组编码',
					'name' => 'RECORD_ID',
						
					'value' =>	'$data["RECORD_ID"]',
			),
		array(
				'header' => '站点名称',
			'name' => 'base_search',
			
			'value' =>	'$data->base->BASE_NAME'
		),   
			//'name' => 'RECORD_ID',
			//'GROUPNAME_V',
			array(
					'header' => '电池规格',
					'name' => 'BATTERYTYPE_V',
					'value' => '$data->dictbattery->BATTERYTYPE_V',
			),
			array(
					'name' => '电池数量',
					'value' => '$data["BATTERYNUM_N"]',
			),
			
			array(
					'header' => '电池组状态',
					'name' =>'STATUS_N',
					'type' => 'raw',
					'value' => '$data["STATUS_N"] == 0 ? "<img src=\"'.Yii::app()->baseUrl.'/images/green.png\"/>" : ($data["STATUS_N"] == 1 ? "<img src=\"'.Yii::app()->baseUrl.'/images/yellow.gif\"/>" : "<img src=\"'.Yii::app()->baseUrl.'/images/red.gif\"/>") ',
			), 
			array(
					'name' => '事件数量',
					'value' => '$data["EVENT_NUM"]',
			),
			/*
			'BATTERYTYPE_V',
			'BATTERYNUM_N',
			'EVENT_NUM',
			'RED',
			'YELLOW',		
		'STATUS_N', */
//		'TESTVOLUME_N',
//		'POWERSUPPLY_N',
//		'BACKLOAD_N',
//		'REMARK_V',

		array(
			'class'=>'CButtonColumn',
			'header' => '操作',
			'template'=>'{view}{update}{delete}{contrast}{event}',
				'buttons'=>array
				(
						'view' => array
						(
								'label'=>'详情',
								'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page.png',
								'url'=>'Yii::app()->createUrl("btBattery/views", array("id"=>$data["RECORD_ID"]))',
						),
						'update' => array
						(
								'label'=>'修改',
								'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_edit.png',
								'url'=>'Yii::app()->createUrl("btBattery/updates", array("id"=>$data["RECORD_ID"]))',
						),
						'delete' => array
						(
								'label'=>'删除',
								//'url'=>'"#"',
								'visible'=>'true',
								'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
								//'visible'=>'$data->score > 0',
								'url'=>'Yii::app()->createUrl("btBattery/deletes", array("id"=>$data["RECORD_ID"]))',
						),
						
						'contrast' => array
						(
								'label'=>'对比图',
								'imageUrl'=>Yii::app()->request->baseUrl.'/images/charts.png',
								'url'=>'Yii::app()->createUrl("btBattery/charts", array("id"=>$data["RECORD_ID"]))',
								//'visible'=>'true',
								//'click'=>'function(){alert("Going down!");}',
						),
						'event' => array
						(
								'label'=>'事件',
								'imageUrl'=>Yii::app()->request->baseUrl.'/images/event.png',
								'url'=>'Yii::app()->createUrl("event/admin", array("id"=>$data["RECORD_ID"]))',
						),

				),

			//'viewButtonLabel'=>'事件',
/*
            'viewButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page.png',            
            'updateButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page_edit.png',
            'deleteButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
			'deleteButtonImageUrl'=> Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
*/
		),
	),
    'template'=>'{items}{summary}{pager}',
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css',
)); ?>
</section>

<section class="grid_9" id="dashtabs">
<div class="box-header">
  
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'bt-battery-grid1',

	'dataProvider'=>new CArrayDataProvider($battery, array('keyField'=>'RECORD_ID','sort'=>array(
		'attributes'=>array(
				'FORCASTVOLUME_N','STATUS_N'
		),
),)),
	//'fieldid'=>'RECORD_ID',
	//'filter'=>$model,

	'columns'=>array(

array(
		'name' => '流水号',
		'value' => '$row + 1',
),

array(
		'name' => '电池组名称',
		'value' => '$data->batterys->GROUPNAME_V',
),


array(
		'name' => '电池类型',
		'value' => '$data->dictsort->SORTNAME_V',
),
			 
array(
		'name' => '制造商',
		'value' => '$data->dictmanu->MANNAME_V',
),  
array(
		'name' => '电池规格',
		'value' => '$data->dictbattery->BATTERYTYPE_V',
),  
array(
		'header'=>'电池状态',
		'name' => 'STATUS_N',
	//'value' => '$data',
		'type' => 'raw',
		'value' => '$data["STATUS_N"] == 0 ? "<img src=\"'.Yii::app()->baseUrl.'/images/green.png\"/>" : ($data["STATUS_N"] == 1 ? "<img src=\"'.Yii::app()->baseUrl.'/images/yellow.gif\"/>" : "<img src=\"'.Yii::app()->baseUrl.'/images/red.gif\"/>") ',
),
array(
		'name' => '当前电压(V)',
		//'value' => '$data',
		'value'=> 'number_format($data["CURVAL_N"] ,2)',
),
array(
		'name' => '蓄电池内阻(mΩ)',
		//'value' => '$data',
		'value'=>'number_format($data["CURINNER_N"],3)',
),
array(
		'header'=>'预估容量(Ah)',
		'name' => 'FORCASTVOLUME_N',
		//'value' => '$data',
		'value'=>'number_format($data["FORCASTVOLUME_N"],2) ',
),
/*array(
		'name' => '汇流排电阻(mΩ)',
		//'value' => '$data',
		'value'=>'number_format($data["CUR_HL_INNER_N"],3) ',
),*/

array(
		'name' => '采集时间',
		//'value' => '$data',
		'value'=>'$data["CURDATE_D"]',
),

		array(
			'class'=>'CButtonColumn',
			'header' => '操作',
//			'template'=>'{view}{update}{delete}{history}',
			'template'=>'{view}{delete}{history}',
		'buttons'=>array
		(
			'view' => array
			(

					'label'=>'详情',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page.png',
					//'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->RECORD_ID))',
			),
			'update' => array
			(
					'label'=>'修改',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_edit.png',
					//'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->RECORD_ID))',
			),
			'delete' => array
			(
					'label'=>'删除',
					//'url'=>'"#"',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
					//'click'=>'function(){alert("Going down!");}',
			),
			'history' => array
			(
					'label'=>'历史',
					'imageUrl'=>Yii::app()->request->baseUrl.'/images/history.png',
					'url'=>'Yii::app()->createUrl("btBattery/history", array("gid"=>$data->GROUP_V, "sid"=>$data->SERIAL_N))',
					//'visible'=>'true',
					//'click'=>'function(){alert("Going down!");}',
			),
		),
	),
),
    'template'=>'{items}{summary}{pager}',
    'htmlOptions'=>array(
    	'class'=>'cgridview'
    ),
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css',
)); ?>
</section>





